﻿using ContactSMS.Domain.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace ContactSMS.Infrastructure.Configs
{
    public class PhoneConfig : IEntityTypeConfiguration<Phone>
    {
        public void Configure(EntityTypeBuilder<Phone> builder)
        {
            builder.ToTable($"T_{nameof(Phone)}", t => t.HasComment("电话表"));
            builder.HasKey(t => t.Id);
            builder.Property(t => t.UserId).HasComment("用户id").HasDefaultValue(0);
            builder.Property(t => t.ContactId).IsRequired().HasComment("联系人id");
            builder.Property(t => t.Mobile).HasColumnType("VARCHAR(20)").HasComment("电话");
            builder.Property(t => t.Tag).HasColumnType("VARCHAR(20)").HasComment("标签");
            builder.Property(t => t.CreatTime).HasComment("创建时间");
            builder.Property(t => t.UpdateTime).HasComment("更新时间");
        }
    }
}
